/** @jsxImportSource @emotion/react */
import * as React from "react";
import {Text, useTheme,} from "customize-easy-ui-component";
import { ReportViewProps, } from "../../common/base";
import {末尾链接, 注意事项, 落款单位地址,} from "../../common/rarelyVary";
import {检验结论报告,} from "./repView";
import {useSubRepMain} from "../../hook/useSubRepMain";
import {useRepMenuDirItems} from "../../hook/useMainRepUrlOr";
import {宏观检验报告} from "../viewMacr";
import {资料审查报告} from "../viewReview";
import {ReportFirstPageHeadAllNmbbm, 注意事项Cont, 检验项目表Cot, 首页设备概况Ct} from "../rarelyVary";
import {VsProjects默认} from "../editorJJ";
import {useItemsMapPressure} from "../../common/pressure";
import {安全附件检验} from "../viewSAcces";
import {CertificatePage} from "../viewCert";

/*分项还没遇的：
    {name:'耐压试验报告',ha:''},
    {name:'泄漏试验报告',ha:''},
    {name:'射线底片审查',ha:''},
    {name:'金相分析报告' },
* */
export const ReportView: React.FunctionComponent<ReportViewProps> = ({
    repId,   source: orc,  verId,rep,
}) => {
    const theme= useTheme();
    const [mapFxian]=useItemsMapPressure({ projects:orc.Projects });
    const [renderThickm]= useSubRepMain("cm/thickm", {nestMd:'THICK_MS',orc, repId:repId!, rep, NestMbVer:1});
    const [rootMenu]=useRepMenuDirItems(VsProjects默认, orc.Projects, `/reportView/${rep?.modeltype}/ver/${verId}/${repId}`);
    const [renderUtrSonic]= useSubRepMain("cm/sonic", {nestMd:'SONIC_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderRadioTs ]= useSubRepMain("cm/radio", {nestMd:'RADIO_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [permeation ]= useSubRepMain("cm/permeation", {nestMd:'PERME_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [magnetic ]= useSubRepMain("cm/magnetic", {nestMd:'MAGNT_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [optical ]= useSubRepMain("cm/optical", {nestMd:'OPTIC_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [hardness ]= useSubRepMain("cm/hardness", {nestMd:'HARD_TS',orc, repId:repId!, rep, NestMbVer:1});
  return (
    <React.Fragment>
        {rootMenu}
        <div css={{"@media not print": {marginTop: '1rem', marginBottom: '1rem'}}}>
          { orc?.检验结论==='符合' &&
                <CertificatePage orc={orc} rep={rep}/>
          }
          <div css={{
              display: 'flex',
              flexDirection: 'column',
              justifyContent: 'space-between',
              "@media print": {height:'100vh', pageBreakInside: 'avoid',}
          }}>
                {ReportFirstPageHeadAllNmbbm({theme, rep, mbbm: 'FJB/TM-1007-1-0-2022'})}
                <div>
                    <Text variant="h3" css={{
                        textAlign: 'center',
                        "@media (min-width:690px),print and (min-width:538px)": {
                            fontSize: theme.fontSizes[6],
                    }} }>
                    进口压力容器安全性能监督检验检报告
                    </Text>
                    <br css={{"@media not print": {display: 'none'}}}/>
                    <Text variant="h5" css={{
                        textAlign: 'center',
                    }}> （ FJB/RC10372-2022 ）
                    </Text>
                </div>
                <div>
                    {首页设备概况Ct({theme, orc, rep})}
                </div>
                <div css={{textAlign: 'center', "@media print": {pageBreakInside: 'avoid'}}}>
                    {落款单位地址}
                </div>
           </div>

            {注意事项Cont({
                rep,
                comply: '书为依据《中华人民共和国特种设备安全法》《中华人民共和国进出口商品检验法》《中华人民共和国进出口商品检验法实施条例》《固定式压力容器安全技术监察规程》' +
                    '（TSG21-2016）相关安全技术规范、标准、设计文件制定，适用于进口压力容器安全性能监督检验报告的结论报告'
            })}

            <Text id={'ProjectList'} variant="h2" css={{textAlign:'center',
                "@media print": {pageBreakBefore: 'always'}
            }}>进口压力容器安全性能监督检验项目表</Text>
            {检验项目表Cot({theme, orc, rep})}
            {检验结论报告({theme, orc, rep})}
            {资料审查报告({theme, orc, rep})}
            {宏观检验报告({theme, orc, rep})}

            {mapFxian.get('壁厚测定报告')?.do && <>
                {renderThickm}
               </>
            }
            {mapFxian.get('安全附件检验报告')?.do &&
                安全附件检验({theme, orc, rep})
            }
            {mapFxian.get('渗透检测报告')?.do && <>
                {permeation}
            </>}
            {mapFxian.get('射线检测报告')?.do && <>
                {renderRadioTs}
            </>}
            {mapFxian.get('磁粉检测报告')?.do && <>
                {magnetic}
            </>}
            {mapFxian.get('光谱检测报告')?.do && <>
                {optical}
            </>}
            {mapFxian.get('硬度检测报告')?.do && <>
                {hardness}
            </>}
            {mapFxian.get('超声检测报告')?.do && <>
                {renderUtrSonic}
            </>}
        </div>
        {末尾链接({template: rep?.modeltype, verId, repId: repId || ''})}
    </React.Fragment>
  );
}

